﻿@using Model.Admin;
@using Xproject.Util;
@{
    ViewBag.Title = "Home Page";
    List<AdminMenu> menues = (List<AdminMenu>)ViewData["menus"];
    if (menues == null) {
        menues = new List<AdminMenu>();
    }
    List<AdminMenu> firstLevel =  menues.Where(i => i.MenuLevel == 1).ToList();
    List<AdminMenu> secondLevel = menues.Where(i => i.MenuLevel == 2).ToList();
    List<AdminMenu> thirdLevel = menues.Where(i => i.MenuLevel == 3).ToList();
    Layout = null;
    string Domain = CommonHelper.GetAppSettings("Domin");
    AdminUser CurrentUser = (AdminUser)ViewBag.CurrentUser;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>辣时光后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <link rel="shortcut icon" href="favicon.ico">
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/font-awesome.min.css" rel="stylesheet" />
    <link href="~/Content/animate.css" rel="stylesheet" />
    <link href="~/Content/Index/style.css" rel="stylesheet" />
</head>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
    <div id="wrapper">
        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="nav-close">
                <i class="fa fa-times-circle"></i>
            </div>
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <span class="clear">
                                    <span class="block m-t-xs" style="font-size:20px;">
                                        <i class="fa fa-area-chart"></i>
                                        <strong class="font-bold">辣时光</strong>
                                    </span>
                                </span>
                            </a>
                        </div>
                        <div class="logo-element">
                            hAdmin
                        </div>
                    </li>

                   

                    @foreach (AdminMenu am in firstLevel)
                    {
                        List<AdminMenu> thissecond = secondLevel.Where(i => i.MenuParentId == am.MenuId).ToList();
                        bool hassecond = false;
                        if (thissecond != null && thissecond.Count > 0)
                        {
                            hassecond = true;
                        }
                        <li>
                            <a href="#"><i class="@am.MenuIcon"></i> <span class="nav-label">@am.MenuName</span>
                                @if (hassecond) {
                                <span class="fa arrow"></span>
                                }
                            </a>
                            <ul class="nav nav-second-level">
                                @foreach (AdminMenu sam in thissecond)
                                {
                                    List<AdminMenu> thisthird = thirdLevel.Where(i => i.MenuParentId == sam.MenuId).ToList();
                                    bool hasthird = false;
                                    if (thisthird != null && thisthird.Count > 0)
                                    {
                                        hasthird = true;
                                    }

                                <li>
                                   @if (hasthird)
                                   {                                   
                                    <a  href="#"><span class="nav-label">@sam.MenuName</span> <span class="fa arrow"></span></a>                                   
                                    <ul class="nav nav-third-level">
                                        @foreach (AdminMenu tam in thisthird)
                                        {
                                            <li>
                                                <a class="J_menuItem" href="@(Domain+tam.MenuUrl)">@tam.MenuName</a>
                                            </li>
                                         }
                                    </ul>
                                   }
                                   else {
                                    <a class="J_menuItem" href="@(Domain+sam.MenuUrl)">@sam.MenuName</a>
                                   }
                                </li>

                                }
                            </ul>
                        </li>
                    }


                </ul>
            </div>
        </nav>
        <!--左侧导航结束-->
        <!--右侧部分开始-->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                    <div class="navbar-header">
                        <a class="navbar-minimalize minimalize-styl-2 btn btn-info " href="#"><i class="fa fa-bars"></i> </a>
                        <form role="search" class="navbar-form-custom" method="post" action="search_results.html">
                            <div class="form-group">
                                <input type="text" placeholder="请输入您需要查找的内容 …" class="form-control" name="top-search" id="top-search">
                            </div>
                        </form>
                    </div>
                    <ul class="nav navbar-top-links navbar-right">
                        <li class="dropdown">
                            <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
                                <i class="fa fa-envelope"></i> <span class="label label-warning">16</span>
                            </a>
                            <ul class="dropdown-menu dropdown-messages">
                                <li class="m-t-xs">
                                    <div class="dropdown-messages-box">
                                        <a href="profile.html" class="pull-left">
                                            <img alt="image" class="img-circle" src="img/a7.jpg">
                                        </a>
                                        <div class="media-body">
                                            <small class="pull-right">46小时前</small>
                                            <strong>小四</strong> 是不是只有我死了,你们才不骂爵迹
                                            <br>
                                            <small class="text-muted">3天前 2014.11.8</small>
                                        </div>
                                    </div>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <div class="dropdown-messages-box">
                                        <a href="profile.html" class="pull-left">
                                            <img alt="image" class="img-circle" src="img/a4.jpg">
                                        </a>
                                        <div class="media-body ">
                                            <small class="pull-right text-navy">25小时前</small>
                                            <strong>二愣子</strong> 呵呵
                                            <br>
                                            <small class="text-muted">昨天</small>
                                        </div>
                                    </div>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <div class="text-center link-block">
                                        <a class="J_menuItem" href="mailbox.html">
                                            <i class="fa fa-envelope"></i> <strong> 查看所有消息</strong>
                                        </a>
                                    </div>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
                                <i class="fa fa-bell"></i> <span class="label label-primary">8</span>
                            </a>
                            <ul class="dropdown-menu dropdown-alerts">
                                <li>
                                    <a href="mailbox.html">
                                        <div>
                                            <i class="fa fa-envelope fa-fw"></i> 您有16条未读消息
                                            <span class="pull-right text-muted small">4分钟前</span>
                                        </div>
                                    </a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a href="profile.html">
                                        <div>
                                            <i class="fa fa-qq fa-fw"></i> 3条新回复
                                            <span class="pull-right text-muted small">12分钟钱</span>
                                        </div>
                                    </a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <div class="text-center link-block">
                                        <a class="J_menuItem" href="notifications.html">
                                            <strong>查看所有 </strong>
                                            <i class="fa fa-angle-right"></i>
                                        </a>
                                    </div>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <img alt="" src="images/2.png">
                                <span class="username">@(CurrentUser!=null? CurrentUser.UserName:"")</span>
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu extended logout">
                                <li><a href="#" onclick="EditUserInfo();"><i class=" fa fa-suitcase"></i>个人信息</a></li>
                                <li><a href="#"><i class="fa fa-cog"></i> Settings</a></li>
                                <li><a href="#" onclick="LogOut()"><i class="fa fa-key"></i> Log Out</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="row J_mainContent" id="content-main">
                <iframe id="J_iframe" width="100%" height="100%" src="~/Home/DashBoard" frameborder="0" data-id="index_v1.html" seamless></iframe>
            </div>
        </div>
        <!--右侧部分结束-->
    </div>
    <!-- 全局js -->
    <script src="~/Scripts/jquery-2.1.4.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="~/Scripts/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="~/Scripts/plugins/layer/layer.min.js"></script>
    <!-- 第三方插件 -->
    <script src="~/Scripts/plugins/pace/pace.min.js"></script>
    <!-- 自定义js -->
    <script src="~/Scripts/index/hAdmin.js"></script>
    <script src="~/Scripts/index/index.js"></script>
    <script type="text/javascript">

       function EditUserInfo() {
            layer.open({
                type: 2,
                title: '个人信息',
                shadeClose: true,
                shade: 0.8,
                area: ['800px', '60%'],
                end: function (index) {

                },
                content: '@(Domain+"/UserInfo/EditUserInfo?userId="+(CurrentUser!=null? CurrentUser.UserID:0))' //iframe的url
            });
        }

        function LogOut() {
              $.ajax({
                         url: "@(Domain+ "/Login/LogOut")",
                    type: 'post',
                    cache: 'false',
                    async: 'false',
                    data: { },
                    success: function (data) {
                        window.location.href= '@(Domain+"/Login/Login")'
                     },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {

                        }
                    });
        }
    </script>
</body>
</html>
